package com.woniuxy.micromallserver.ordermag.controller;

import com.woniuxy.common.bean.PageDto;
import com.woniuxy.common.bean.ResultMsg;
import com.woniuxy.micromallserver.bean.AfterSaleServiceBean;
import com.woniuxy.micromallserver.ordermag.service.IAfterSaleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author unreleased
 * @date 2021/2/1 11:29
 */
@RestController
@RequestMapping("/afterService")
public class AfterServiceController {
    @Resource
    private IAfterSaleService afterSaleServiceImpl;
    @GetMapping(value = "/getList")
    public ResultMsg getAfterServiceList(AfterSaleServiceBean afterSaleServiceBean, Integer pageNum, Integer pageSize){
        ResultMsg resultMsg = new ResultMsg();
        PageDto pageDto = afterSaleServiceImpl.findAfterSaleServiceListByParams(afterSaleServiceBean,pageNum,pageSize);
        if (pageDto == null) {
            return resultMsg.setCode(10000).setMessage("系统繁忙，请稍后再试");
        }
        return resultMsg.setCode(200).setMessage("查询成功").setData(pageDto);
    }
    @PutMapping("/handle")
    public ResultMsg updateStatus(Long id,String handleStatus){
        ResultMsg resultMsg = new ResultMsg();
        if(afterSaleServiceImpl.updateStatus(id,handleStatus)){
            return resultMsg.setCode(200).setMessage("操作成功");
        }else {
            return resultMsg.setCode(10000).setMessage("操作失败");
        }
    }
}
